package com.jewelry.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jewelry.dao.ICustomerDAO;
import com.jewelry.service.ICustomerService;
import com.jewelry.service.ISeqService;
import com.jewelry.vo.CustomerVO;

public class CustomerServiceImpl implements ICustomerService{
	
	private static Logger logger = LoggerFactory.getLogger(CustomerServiceImpl.class); 
	
	private ICustomerDAO customerDAO;

	public ICustomerDAO getCustomerDAO() {
		return customerDAO;
	}

	public void setCustomerDAO(ICustomerDAO customerDAO) {
		this.customerDAO = customerDAO;
	}
	
	private ISeqService seqService;

	public ISeqService getSeqService() {
		return seqService;
	}

	public void setSeqService(ISeqService seqService) {
		this.seqService = seqService;
	}
	
	//=========================================================

	@Override
	public List<CustomerVO> getCustomerListByPage(CustomerVO vo) {
		int totalCount = customerDAO.getCustomerCount(vo);
		vo.getPage().setTotalItem(totalCount);
		List<CustomerVO> list = customerDAO.getCustomerListByPage(vo);
		return list;
	}

	@Override
	public int getCustomerCount(CustomerVO customer) {
		return customerDAO.getCustomerCount(customer);
	}
	
	public String getCustomerID(){
		return seqService.getCustomerID();
	}
	
	public void addCustomer(CustomerVO customer){
		if(logger.isDebugEnabled()){
			logger.debug("start add customer customerid="+customer.getCustomerid());
		}
		customerDAO.addCustomer(customer);
	}

	@Override
	public List<CustomerVO> getCustomerList(CustomerVO vo) {
		return customerDAO.getCustomerList(vo);
	}
	
}
